<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">


    <title>实验室助理管理系统</title>
    <meta name="keywords" content="H+后台主题,后台bootstrap框架,会员中心主题,后台HTML,响应式后台">
    <meta name="description" content="H+是一个完全响应式，基于Bootstrap3最新版本开发的扁平化主题，她采用了主流的左右两栏式布局，使用了Html5+CSS3等现代技术">

    <link rel="shortcut icon" href="favicon.ico">
    <link href="css/bootstrap.min.css" rel="stylesheet">
    <link href="css/font-awesome.css" rel="stylesheet">

    <link href="css/animate.css" rel="stylesheet">
    <link href="css/style.css" rel="stylesheet">
    <!--[if lt IE 9]>
    <meta http-equiv="refresh" content="0;ie.html"/>
    <![endif]-->
    <script>if (window.top !== window.self) {
        window.top.location = window.location;
    }</script>
</head>

<body class="gray-bg">

<div class="middle-box text-center loginscreen  animated fadeInDown">
    <div>
        <div>

            <h1 class="logo-name">H+</h1>

        </div>
        <h3>欢迎使用 实验室助理管理系统</h3>

        <form class="m-t">
            <div class="form-group">
                <input type="username" id="username" name="username" class="form-control" placeholder="用户名" required="">
            </div>
            <div class="form-group">
                <input type="password" id="password" name="password" class="form-control" placeholder="密码" required="">
            </div>
            <div class="form-group">
                <select class="form-control m-b" id="type" name="type" lay-verify="type">
                    <option>请选择角色</option>
                    <option value="0">管理员</option>
                    <option value="1">实验室技术员</option>
                    <option value="2">学生</option>
                    <option value="3">实验室助理</option>
                    <option value="4">学工处</option>
                </select>
            </div>
            <button type="button" onclick="login()" class="btn btn-primary block full-width m-b">登 录</button>


            <p class="text-muted text-center"><a href="#"><small>忘记密码了？</small></a> | <a th:href="@{/toRegister}">注册一个新账号</a>
            </p>

        </form>
    </div>
</div>

<!-- 全局js -->
<script src="js/jquery.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<!-- layer javascript -->
<script th:src="@{/js/layer.min.js}"></script>
<script th:src="@{/js/layer-demo.js}"></script>

<script>
    function login() {

        var username = $('#username').val();
        var password = $('#password').val();
        var type = $('#type').val();
        if (username == null && username == "") {
            alert("用户名不能为空！")
        } else if (password == null && password == "") {
            alert("密码不能为空！")
        } else if (type == null && type == "") {
            alert("请选择角色！")
        } else {
            $.ajax({
                type: "post",
                url: "http://localhost:9527/sysLab/login/check",
                async: false,
                dataType: 'json',
                data: {
                    username: username,
                    password: password,
                    type: type
                },
                success: function (res) {
                    if (res.data == "success") {
                        //alert("登录成功！");
                        layer.msg("登录成功！", {time:5000});
                        location.href = "http://localhost:9527/sysLab/toIndex";
                    } else {
                        alert(res.msg);
                    }
                },
                error: function () {
                    alert("服务出错！请联系管理员")
                }
            })

        }
        //alert("==>"+type);

    }
</script>


</body>

</html>
